手动修复Under-replicated Blocks

  • 切换到hdfs用户,否则会报Access denied
    1
    su - hdfs
  • 将Under-replicated Blocks写入临时文件

    1
    hdfs fsck / | grep 'Under replicated' | awk -F':' '{print $1}' >> /tmp/under_replicated_files
  • 修改replication factor

    1
    for hdfsfile in `cat /tmp/under_replicated_files`; do echo "Fixing $hdfsfile :" ;  hadoop fs -setrep 3 $hdfsfile; done